{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}{{!

This template should always mirror services.pyx but for mypy typing

}}
{{> common/auto_generated_py}}

import folly.iobuf as _fbthrift_iobuf
import typing as _typing
from thrift.py3.server import RequestContext, ServiceInterface
from abc import abstractmethod, ABCMeta

import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types
{{#program:includeNamespaces}}
{{#hasServices?}}
import {{#includeNamespace}}{{value}}.{{/includeNamespace}}services as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}services
{{/hasServices?}}
{{#hasTypes?}}
import {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types
{{/hasTypes?}}
{{/program:includeNamespaces}}

{{#program:services}}
_{{service:name}}InterfaceT = _typing.TypeVar('_{{service:name}}InterfaceT', bound='{{service:name}}Interface')


class {{service:name}}Interface(
    {{#service:extends}}{{#service:externalProgram?}}
    _{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{!
        }}{{service:programName}}_services.{{/service:externalProgram?}}{{service:name}}Interface,
    {{/service:extends}}
    {{^service:extends?}}
    ServiceInterface,
    {{/service:extends?}}
    metaclass=ABCMeta,
):
    {{#service:supportedFunctions}}

    {{#function:return_type}}
    {{#function:stream?}}
    @staticmethod
    def createPublisher_{{function:name}}(callback=None) -> _typing.Tuple[
        _typing.AsyncGenerator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}, None],
        _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types.{{#function:stream_elem_type}}ServerPublisher_{{> types/cython_cpp_type_ident}}{{/function:stream_elem_type}}
    ]: ...

    {{/function:stream?}}
    {{/function:return_type}}

    @abstractmethod
    {{#function:return_type}}{{^function:stream?}}async {{/function:stream?}}{{#function:stream_has_first_response?}}async {{/function:stream_has_first_response?}}{{/function:return_type}}def {{function:name}}(
        self{{#function:args}},
        {{field:py_name}}: {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/function:args}}
    ) -> {{#function:return_type}}{{> services/return_type_pep484_type}}{{/function:return_type}}: ...
    {{/service:supportedFunctions}}
    pass


{{/program:services}}
